/* generation-animation.css — Animation system for fit generation
   Phase 1: Tag collage over inspos
   Phase 2: Liquid morph to bubble
   Phase 3: Closet burst
*/

/* =================== Phase 1: Generation Overlay & Tag Collage =================== */

.gen-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(250, 250, 250, 0.98);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.gen-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Collage container - holds inspo images and accumulating tags */
.gen-collage {
    position: relative;
    width: min(90vw, 400px);
    aspect-ratio: 1;
    display: grid;
    gap: 8px;
    perspective: 1000px;
}

.gen-collage.inspos-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gen-collage.inspos-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Inspo image in the collage */
.gen-inspo {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #F4F4F4;
    animation: gen-inspo-float 3s ease-in-out infinite;
}

.gen-inspo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes gen-inspo-float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-4px) rotate(0.5deg);
    }
}

.gen-inspo:nth-child(2) {
    animation-delay: -1s;
}

.gen-inspo:nth-child(3) {
    animation-delay: -2s;
}

/* Tag pills that appear during generation */
.gen-tag {
    position: absolute;
    z-index: 10;
    padding: 6px 12px;
    border-radius: 2px;
    background: var(--card);
    border: 1px solid var(--edge);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink);
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) translateY(20px);
    animation: gen-tag-appear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

@keyframes gen-tag-appear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

/* Tag color variations based on type */
.gen-tag.name {
    background: var(--ink);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 14px;
    z-index: 20;
}

.gen-tag.tagline {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: #fff;
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
}

.gen-tag.key-piece {
    background: rgba(78, 205, 196, 0.15);
    border-color: #4ecdc4;
}

.gen-tag.material {
    background: rgba(199, 125, 255, 0.15);
    border-color: #c77dff;
}

.gen-tag.silhouette {
    background: rgba(255, 230, 109, 0.15);
    border-color: #ffe66d;
}

.gen-tag.color-story {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(78, 205, 196, 0.2));
    border-color: var(--edge);
}

/* Generation status text */
.gen-status {
    margin-top: 24px;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    animation: gen-pulse 1.5s ease-in-out infinite;
}

@keyframes gen-pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* =================== Phase 2: Liquid Morph Bubble =================== */

.gen-bubble {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #c77dff);
    background-size: 200% 200%;
    animation: gen-bubble-gradient 2s ease infinite;
    opacity: 0;
    transform: scale(0);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    z-index: 100;
}

.gen-bubble.growing {
    opacity: 1;
    transform: scale(1);
}

.gen-bubble.expanded {
    width: min(90vw, 400px);
    height: min(90vw, 400px);
    border-radius: 4px;
}

.gen-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.gen-bubble.revealed img {
    opacity: 1;
}

@keyframes gen-bubble-gradient {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* Liquid filter effect */
.gen-collage.morphing {
    filter: url(#liquid-morph);
    transition: transform 0.8s ease, opacity 0.8s ease;
    transform: scale(0.3);
    opacity: 0;
}

/* =================== Phase 3: Closet Burst =================== */

.gen-burst-card {
    position: fixed;
    z-index: 1000;
    width: 120px;
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: gen-burst-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.gen-burst-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

@keyframes gen-burst-pop {
    0% {
        transform: scale(1.5) rotate(-5deg);
        opacity: 1;
    }

    20% {
        transform: scale(1.8) rotate(5deg);
    }

    100% {
        transform: scale(0.5) rotate(0deg);
        opacity: 0;
    }
}

/* Burst particles */
.gen-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1001;
    animation: gen-particle-fly 0.8s ease-out forwards;
}

@keyframes gen-particle-fly {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0) translate(var(--tx), var(--ty));
        opacity: 0;
    }
}

/* =================== SVG Filter Hidden Container =================== */

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* =================== Accessibility: Reduce Motion =================== */

@media (prefers-reduced-motion: reduce) {

    /* Disable floating animation */
    .gen-inspo {
        animation: none;
    }

    /* Simplify tag appearance - just fade in without movement */
    .gen-tag {
        animation: gen-tag-fade-in 0.5s ease forwards;
        transform: translate(-50%, -50%);
        transition: none;
    }

    @keyframes gen-tag-fade-in {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Disable pulse on status text */
    .gen-status {
        animation: none;
    }

    /* Disable liquid morph filter and scale transform */
    .gen-collage.morphing {
        filter: none;
        transform: scale(0.9);
        opacity: 0;
        transition: opacity 0.5s ease;
    }

    /* Simplify bubble growth - just scale up simply */
    .gen-bubble {
        animation: none;
        background: var(--card);
        /* Solid background instead of shifting gradient */
        transition: opacity 0.4s ease, transform 0.4s ease;
    }

    /* Reveal image with simple fade */
    .gen-bubble.revealed img {
        transition: opacity 0.3s ease;
    }

    /* Simplify burst - just fade out/move linearly */
    .gen-burst-card {
        animation: none;
        transition: opacity 0.5s ease, transform 0.5s ease, top 0.5s ease, left 0.5s ease !important;
    }

    /* Disable particles */
    .gen-particle {
        display: none;
    }
}